lease = NULL;
}
- if (lease && (lease->flags & OAF_BOUND) && lease->fr_ip) {
+ if (lease && lease->bound && lease->fr_ip) {
*fr_serverid = lease->fr_ip->addr.addr.in.s_addr;
dhcpv4_fr_stop(lease);
}
if (!lease)
return NULL;
- lease->flags &= ~OAF_BOUND;
+ lease->bound = false;
if (!lease->lease_cfg || lease->lease_cfg->ipv4.s_addr != lease->ipv4.s_addr) {
memset(lease->hwaddr, 0, sizeof(lease->hwaddr));
*req_leasetime = max_leasetime;
if (req_msg == DHCPV4_MSG_DISCOVER) {
- lease->flags &= ~OAF_BOUND;
+ lease->bound = false;
*reply_incl_fr = req_accept_fr;
lease->valid_until = now;
break;
}
*reply_incl_fr = false;
- if (!(lease->flags & OAF_BOUND)) {
+ if (!lease->bound) {
/* This is the client's first request for the address */
if (req_accept_fr) {
lease->accept_fr_nonce = true;
*reply_incl_fr = true;
odhcpd_urandom(lease->key, sizeof(lease->key));
}
- lease->flags |= OAF_BOUND;
+ lease->bound = true;
}
if (*req_leasetime == UINT32_MAX)
}
avl_for_each_element(&iface->dhcpv4_leases, lease, iface_avl) {
- if ((lease->flags & OAF_BOUND) && lease->fr_ip && !lease->fr_cnt) {
+ if (lease->bound && lease->fr_ip && !lease->fr_cnt) {
if (lease->accept_fr_nonce || iface->dhcpv4_forcereconf)
dhcpv4_fr_rand_delay(lease);
else
list_del(&a->head);
list_del(&a->lease_cfg_list);
- if ((a->flags & OAF_BOUND) && (a->flags & OAF_DHCPV6_PD))
+ if (a->bound && (a->flags & OAF_DHCPV6_PD))
apply_lease(a, false);
if (a->fr_cnt)
if (assign->assigned_subnet_id >= current && assign->assigned_subnet_id + asize < c->assigned_subnet_id) {
list_add_tail(&assign->head, &c->head);
- if (assign->flags & OAF_BOUND)
+ if (assign->bound)
apply_lease(assign, true);
return true;
assign->assigned_subnet_id = current;
list_add_tail(&assign->head, &c->head);
- if (assign->flags & OAF_BOUND)
+ if (assign->bound)
apply_lease(assign, true);
return true;
list_for_each_entry(c, &iface->ia_assignments, head) {
if ((c->flags & OAF_DHCPV6_PD) && !(iface->ra_flags & ND_RA_FLAG_MANAGED)
- && (c->flags & OAF_BOUND))
+ && (c->bound))
__apply_lease(c, info->addrs_old.addrs,
info->addrs_old.len, false);
}
if (c->assigned_subnet_id >= border->assigned_subnet_id)
list_move(&c->head, &reassign);
- else if (c->flags & OAF_BOUND)
+ else if (c->bound)
apply_lease(c, true);
if (c->accept_fr_nonce && c->fr_cnt == 0) {
a = c;
/* Reset state */
- if (a->flags & OAF_BOUND)
+ if (a->bound)
apply_lease(a, false);
stop_reconf(a);
/* Was only a solicitation: mark binding for removal in 60 seconds */
if (assigned && hdr->msg_type == DHCPV6_MSG_SOLICIT && !rapid_commit) {
- a->flags &= ~OAF_BOUND;
+ a->bound = false;
a->valid_until = now + 60;
} else if (assigned &&
}
}
a->accept_fr_nonce = accept_reconf;
- a->flags |= OAF_BOUND;
+ a->bound = true;
apply_lease(a, true);
} else if (!assigned) {
/* Cleanup failed assignment */
hdr->msg_type == DHCPV6_MSG_REBIND) {
ia_response_len = build_ia(buf, buflen, status, ia, a, iface, false);
if (a) {
- a->flags |= OAF_BOUND;
+ a->bound = true;
apply_lease(a, true);
}
} else if (hdr->msg_type == DHCPV6_MSG_RELEASE) {
a->valid_until = now - 1;
} else if ((a->flags & OAF_DHCPV6_NA) && hdr->msg_type == DHCPV6_MSG_DECLINE) {
- a->flags &= ~OAF_BOUND;
+ a->bound = false;
if (!a->lease_cfg || a->lease_cfg->hostid != a->assigned_host_id) {
memset(a->duid, 0, a->duid_len);
break;
}
- if (!ia_addr_present || !a || !(a->flags & OAF_BOUND)) {
+ if (!ia_addr_present || !a || !a->bound) {
response_len = 0;
goto out;
}
enum odhcpd_assignment_flags {
- OAF_BOUND = (1 << 0),
- OAF_DHCPV6_NA = (1 << 1),
- OAF_DHCPV6_PD = (1 << 2),
+ OAF_DHCPV6_NA = (1 << 0),
+ OAF_DHCPV6_PD = (1 << 1),
};
/* 2-byte type + 128-byte DUID, RFC8415, §11.1 */
struct lease_cfg *lease_cfg; // host lease cfg, nullable
struct in_addr ipv4; // client IPv4 address
- unsigned int flags; // OAF_*
+ bool bound; // the lease has been accepted by the client
time_t valid_until; // CLOCK_MONOTONIC time, 0 = inf
char *hostname; // client hostname
bool hostname_valid; // is the hostname one or more valid DNS labels?
uint8_t length; // length == 128 -> IA_NA, length <= 64 -> IA_PD
unsigned int flags;
+ bool bound; // the lease has been accepted by the client
uint32_t leasetime;
char *hostname;
bool hostname_valid; // is the hostname one or more valid DNS labels?
struct dhcpv6_lease *lease;
list_for_each_entry(lease, &ctxt.iface->ia_assignments, head) {
- if (!(lease->flags & OAF_BOUND))
+ if (!lease->bound)
continue;
if (!INFINITE_VALID(lease->valid_until) && lease->valid_until <= now)
struct dhcpv4_lease *lease;
avl_for_each_element(&ctxt.iface->dhcpv4_leases, lease, iface_avl) {
- if (!(lease->flags & OAF_BOUND))
+ if (!lease->bound)
continue;
if (!INFINITE_VALID(lease->valid_until) && lease->valid_until <= now)
struct dhcpv6_lease *lease;
list_for_each_entry(lease, &ctxt.iface->ia_assignments, head) {
- if (!(lease->flags & OAF_BOUND))
+ if (!lease->bound)
continue;
if (!INFINITE_VALID(lease->valid_until) && lease->valid_until <= now)
struct dhcpv4_lease *lease;
avl_for_each_element(&ctxt.iface->dhcpv4_leases, lease, iface_avl) {
- if (!(lease->flags & OAF_BOUND))
+ if (!lease->bound)
continue;
if (!INFINITE_VALID(lease->valid_until) && lease->valid_until <= now)
blobmsg_add_u8(&b, "accept-reconf", c->accept_fr_nonce);
m = blobmsg_open_array(&b, "flags");
- if (c->flags & OAF_BOUND)
+ if (c->bound)
blobmsg_add_string(&b, NULL, "bound");
if (c->lease_cfg)
blobmsg_add_u16(&b, "assigned", a->assigned_subnet_id);
m = blobmsg_open_array(&b, "flags");
- if (a->flags & OAF_BOUND)
+ if (a->bound)
blobmsg_add_string(&b, NULL, "bound");
if (a->lease_cfg)